//微网页自定义提示框
function myAlert(flag,text){
	if(!document.getElementById('alertShow')){
	var divObj=document.createElement("div");
	divObj.setAttribute('id','alertShow');
	divObj.setAttribute('style','width:auto;height:auto;position:fixed;margin-top:220px;margin-left:35%;text-align:center;display:block;z-index:50;padding:10px 30px;background:rgba(0,0,0,0.5);color:#fff');
	var spanclass;
	if(flag=='s'){
	 spanclass='glyphicon glyphicon-ok-sign';
	}else{
	 spanclass='glyphicon glyphicon-exclamation-sign';
	}
	divObj.innerHTML="<span class='"+spanclass+"'></span>&nbsp;"+text;
	var first=document.body.firstChild;//得到页面的第一个元素
	document.body.insertBefore(divObj,first);//在得到的第一个元素之前插入
	//2秒后删除节点
	setTimeout(function() { 
    	var idObject=document.getElementById('alertShow');
    	if (idObject != null) 
            idObject.parentNode.removeChild(idObject); 
    },2500);
	}
}

function myAlert2(icoClass,text){
	if(!document.getElementById('alertShow')){
	var divObj=document.createElement("div");
	divObj.setAttribute('id','alertShow');
	divObj.setAttribute('style','width:94%;height:auto;position:fixed;margin:10px;text-align:center;display:block;z-index:50;padding:10px 0px;background:rgba(0,0,0,0.5);color:#fff');
	var spanclass;
	if(icoClass!=''){
	 divObj.innerHTML="<span class='"+icoClass+"' style='color:#fff;'></span>&nbsp;"+text;
	}else{
	 divObj.innerHTML=text;
	}
	var first=document.body.firstChild;//得到页面的第一个元素
	document.body.insertBefore(divObj,first);//在得到的第一个元素之前插入
	//2秒后删除节点
	setTimeout(function() { 
    	var idObject=document.getElementById('alertShow');
    	if (idObject != null) 
            idObject.parentNode.removeChild(idObject); 
    },2500);
	}
}

//不同的浏览器宽度显示的字体个数不同  其他自动隐藏
function overHide(num,text){
	var eWidth=document.documentElement.clientWidth;
	var defaultWidth=320;
	num=parseInt((eWidth-defaultWidth)/20)+Number(num);
	if(text.length>Number(num)){
		return text.substring(0,Number(num))+'...';
	}else{
		return text;
	}
}

//显示加载图标 并在指定时间后隐藏
function myLoadIco(s){
	document.getElementById('loadIoc').style.display="block";
	setTimeout(function() { 
		document.getElementById('wm-shade').style.display="none";
		document.getElementById('loadIoc').style.display="none";
    },s) ;
}

//验证手机号
	function judgePhone(e){
		 var reg = /^0?1[3|4|5|8][0-9]\d{8}$/;
		 if (!reg.test(e)) {
		      if(e!=''){
		      myAlert2('e','手机号码不正确');
		      return false;
		      }else{
		      myAlert2('e','请输入手机号吗');
		      return false;
		      }
		 }else{
			 return true;
		 }
	}
	
	//将字符串转成json对象 并返回
	function toJSON(str){
		return eval('(' + str + ')');
	}


	function getAreaLittleName(selectId){
		var array = new Array("京","津","冀","晋","蒙","辽","吉","黑","新","藏","宁","桂",
		"港","澳","沪","苏","浙","皖","闽","赣","鲁","豫","鄂","湘","粤","琼","川",
		"贵","云","渝","陕","甘","青","台");
		var selectE = document.getElementById(selectId);
		for(var i = 0;i<array.length;i++){
			selectE.add(new Option(array[i]));
		}
	}
	
	
	
	

